<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <link rel="stylesheet" href="css/iconfont.css">
    <link rel="stylesheet" href="css/login.css">
    <link rel="stylesheet" href="css/base.css">
    <script src="js/jquery-1.11.0.js"></script>
    <script src="layui/layui.js"></script>
    <script src="js/frameAll.js"></script>
    <script>
        layui.use(['form'], function () {
            let form = layui.form;

            $.ajax({
                type: "get",
                url: "/fixedAsset/getUser.do",
                dataType: "Json",
                success: function (data) {
                    if (data.data) {
                        top.location.href = "pages/index.html";
                    }
                }
            });

            var username = getCookie('username');
            if (username) {
                $("input[name=username]").val(username);
            }

            form.on("submit(loginBut)", function (data) {
                let field = data.field;
                $.ajax({
                    type: "post",
                    url: "/fixedAsset/login.do",
                    data: field,
                    dataType: "Json",
                    success: function (data) {
                        switch (data.code) {
                            case 0:
                                top.location.href = "pages/index.html";
                                break;
                            default:
                                noMsg(data.message);
                        }
                    },
                    error: function () {
                        noMsg("连接服务器失败");
                    }
                });
                return false;
            });
        });
    </script>
</head>
<body>
<div class="loginBg"></div>
<div class="login_main">
    <div class="box">
        <div class="left">
            <img src="images/login.gif"/>
            <p>固定资产管理系统</p>
        </div>
        <div class="right">
            <form class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label login_title">
                        <i class="iconfont icon-gerenzhongxin-denglu"></i></label>
                    <div class="layui-input-block login_input">
                        <input type="text" name="username" required lay-verify="required|username" autocomplete="off"
                               placeholder="请输入您的账号" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label login_title">
                        <i class="iconfont icon-mima1"></i></label>
                    <div class="layui-input-block login_input">
                        <input type="password" name="pwd" required lay-verify="required|password"
                               autocomplete="off"
                               placeholder="请输入密码" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="loginBut">登&emsp;录</button>
                </div>
                <div class="layui-form-item" style="text-align: right">
                    <a href="pages/index.html">注&emsp;册</a>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>